import type {LoginForm, TokenInfo} from "@/typings/auth";
import type {Ret} from "@/typings/api";

// export const managerLogin = async (login: LoginForm) => {
//     return HttpUtil.post<TokenInfo>("/manager/login", login);
// }
export const managerLogin = async (login: LoginForm) => {
    return new Promise<Ret<TokenInfo>>((resolve) => {
        let ret: Ret<TokenInfo>;
        if (login.username === "admin" && login.password === "123456") {
            const exampleTokenInfo: TokenInfo = {
                tokenName: "Authorization",
                tokenValue: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx",
                isLogin: true,
                loginId: 12345,
                loginType: "user",
                tokenTimeout: 3600,
                sessionTimeout: 7200,
                tokenSessionTimeout: 1800,
                tokenActivityTimeout: 300,
                loginDevice: "Web",
                tag: "example-data"
            };
            ret = {
                code: 0,
                msg: "success",
                data: exampleTokenInfo,
                time: new Date().toISOString(),
                success: true
            }
        } else {
            ret = {
                code: 1000,
                msg: "用户名或密码错误",
                time: new Date().toISOString(),
                success: false
            }
        }
        resolve(ret);
    })
}